//
//  HQYJingMingInteractionCell.m
//  HONGQIYUN
//
//  Created by LeiHuiwu on 16/12/25.
//  Copyright © 2016年 Haidi. All rights reserved.
//

#import "HQYJingMingInteractionCell.h"

/// model
#import "InteractionInfo.h"

@interface HQYJingMingInteractionCell ()

@property (nonatomic, strong) UILabel *titleLabel;

@property (nonatomic, strong) UIView *lineSeperator;

@property (nonatomic, strong) UIImageView *replyImageView;

@property (nonatomic, strong) UILabel *replyContentLabel;

@end

@implementation HQYJingMingInteractionCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (id)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier {
    if(self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        [self viewLayout];
    }
    return self;
}

- (void)viewLayout {
    
    [self addSubview:self.titleLabel];
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.mas_left).offset(25);
        make.top.equalTo(self.mas_top);
        make.right.equalTo(self.mas_right);
        make.height.equalTo(@(45));
    }];
    
    [self addSubview:self.lineSeperator];
    [self.lineSeperator mas_makeConstraints:^(MASConstraintMaker *make) {
        make.top.equalTo(self.titleLabel.mas_bottom).offset(0.f);
        make.left.equalTo(self.mas_left);
        make.right.equalTo(self.mas_right);
        make.height.equalTo(@(0.5f));
    }];
    
    [self addSubview:self.replyImageView];
    [self.replyImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.titleLabel.mas_left);
        make.top.equalTo(self.lineSeperator.mas_bottom).offset(6);
        make.width.equalTo(@(32));
        make.height.equalTo(@(32));
    }];
    
    [self addSubview:self.replyContentLabel];
    [self.replyContentLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.equalTo(self.replyImageView.mas_right).offset(15);
        make.top.equalTo(self.replyImageView.mas_top);
        make.right.equalTo(self.mas_right);
        make.bottom.equalTo(self.replyImageView.mas_bottom);
    }];
    
    [self setTestDataSource];
}

- (void)setTestDataSource {
    self.titleLabel.text = @"测试数据标题1";
    self.replyImageView.image = [UIImage imageNamed:@"ic_plice"];
    self.replyContentLabel.text = @"克制，不要轻举妄动!";
}

- (void)setInteractionObject:(InteractionObject *)interactionObject {
    if(_interactionObject != interactionObject) {
        _interactionObject = interactionObject;
    }
    
    self.titleLabel.text = _interactionObject.title;
    self.replyImageView.image = [UIImage imageNamed:@"ic_plice"];
    self.replyContentLabel.text = _interactionObject.reply_content;
}
#pragma mark - lazy load
- (UILabel *)titleLabel {
    if(!_titleLabel) {
        _titleLabel = [[UILabel alloc]init];
        _titleLabel.textColor = [UIColor blueColor];
        _titleLabel.font = [UIFont systemFontOfSize:20];
    }
    return _titleLabel;
}

- (UIView *)lineSeperator {
    if(!_lineSeperator) {
        _lineSeperator = [[UIView alloc]init];
        _lineSeperator.backgroundColor = [UIColor colorFromHexString:@"#e2e2e2"];
    }
    return _lineSeperator;
}

- (UIImageView *)replyImageView {
    if(!_replyImageView) {
        _replyImageView = [[UIImageView alloc]init];
    }
    return _replyImageView;
}

- (UILabel *)replyContentLabel {
    if(!_replyContentLabel) {
        _replyContentLabel = [[UILabel alloc]init];
        _replyContentLabel.font = [UIFont systemFontOfSize:13];
        _replyContentLabel.textColor = [UIColor colorFromHexString:@"#707070"];
        _replyContentLabel.numberOfLines = 0;
    }
    return _replyContentLabel;
}

@end
